package com.oms.app.food.dao.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.oms.app.food.dao.IFoodDAO;
import com.oms.app.food.model.Food;
import com.oms.core.dao.impl.GeneralDAO;

/**
 * @author Loong_Mit
 * @date Sep 1, 2012 6:32:12 PM
 */

public class FoodDAOImpl extends GeneralDAO<Food, String> implements IFoodDAO {

	@Override
	public List<Food> getShopList(HttpServletRequest request) {
		List<Food> shopList = this.queryForList("getByShopId", request.getAttribute("shopid"));
		return shopList;
	}

	@Override
	public boolean addFood(Food foodForm) {
		try {
			this.insert(foodForm);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	@Override
	public boolean deleteFood(String PK) {
		try {
			this.delete("delete", PK);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	@Override
	public boolean updateFood(Food foodForm) {
		try {
			this.update("update", foodForm);
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	
	@Override
	public int getFoodSequence(Integer foodId) {
		return this.getCount("getFoodSequence", foodId);
	}
}